package com.xuchaotong.utils;

import com.alibaba.fastjson.JSON;
import com.xuchaotong.entity.ItemLabelDTO;
import java.util.Map;
import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
import org.junit.Before;
import org.junit.Test;

/**
 * @author EASON.TONG
 * @create 2021/04/23
 **/
@Slf4j
public class MapTest {

    private Map<String, ItemLabelDTO> map;

    @Before
    public void init() {
        map = ItemLabelDTO.build();
    }


    @Test
    public void testFilter() {
        Map<String,ItemLabelDTO> filterMap = map.entrySet().stream().filter((e) -> e.getValue().getId() == null)
            .collect(Collectors.toMap((e) -> e.getKey(), (e) -> e.getValue()));


        if (filterMap !=null) {
            System.out.println(JSON.toJSON(filterMap));
        }
    }

}
